<?php

/**
 * Node Types Model
 *
 */
class Application_Model_NodeTypes
{
    
    /**
     * Returns an array with valid node types
     *
     * first one is default
     * 
     * @return array
     */
    static function getValidTypes()
    {
        return Zend_Registry::get('config')->nodeTypes->toArray();
    }
    
    /**
     * Returns default node type
     *
     * @return string
     */
    static function getDefaultType()
    {
        $types=self::getValidTypes();
        
        return $types[0];
    }
    
    /**
     * Checks if given type is valid
     *
     * @param string $type
     * @return bool
     */
    static function isValidType($type)
    {
        if (empty($type)) return false;
        
        $types=self::getValidTypes();
        
        return in_array($type,$types) ? true : false;
    }
    
    /**
     * Returns node type human name
     *
     * @param string $type
     * @return string
     */
    static function getType($type)
    {
        return Zend_Registry::get('locale')->_('node:type:'.$type);
    }
}

